import demo.config.RabbitConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @program: Producer05_topics_springboot
 * @author: 张磊
 * @create: 2019/5/27-12:38
 **/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = RabbitApplication.class)
public class Producer05_topics_springboot {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送消息   email
     * 因为我们使用的是通配模式
     * routKey为：inform.#.email.#   所以#的可以为任意，而匹配inform,和email的一一对应，
     * 而两个队列分别的routingKey为： inform.#.sms.#   和 inform.#.email.#  都可以匹配到
     * 所以这个消息被两个队列都接收到~
     */
    @Test
    public void sendMessage(){
        rabbitTemplate.convertAndSend(RabbitConfig.EXCHANGE_TOPICS_INFORM,"inform.sms.email","你好呀,这是Email消息哦");
    }


    /**
     * 发送消息    SMS
     */
    @Test
    public void sendMessage2(){
        rabbitTemplate.convertAndSend(RabbitConfig.EXCHANGE_TOPICS_INFORM,"inform.sdfkafk.sms","你好呀，这是SMS消息哦");
    }


}
